package staff

import (
	"duoke/service"
	"duoke/tables"
	"duoke/utils/orm"
	"duoke/utils/response"
	"github.com/gin-gonic/gin"
)

var Screenboard = new(screenboardCtl)

type screenboardCtl struct{}

func (ctl *screenboardCtl) Count(c *gin.Context) {
	staffR, _ := service.Request.Staff(c)
	orderNum, _ := orm.Db.Where("goods_id =? AND staff_id =? AND pay_state = 1 AND is_robot = 0 AND refund_state = 0", staffR.GoodsId, staffR.Id).Count(new(tables.Order))
	userNum, _ := orm.Db.Where("goods_id =? AND staff_id =?", staffR.GoodsId, staffR.Id).Count(new(tables.GoodsUser))
	orderNopayNum, _ := orm.Db.Where("goods_id =? AND staff_id =? AND pay_state = 0 AND is_robot = 0 AND refund_state = 0", staffR.GoodsId, staffR.Id).Count(new(tables.Order))
	response.Success(c, "登录成功", gin.H{"order_num": orderNum, "user_num": userNum, "order_nopay_num": orderNopayNum})
}
